package com.jt.controller;

import com.jt.pojo.ItemCat;
import com.jt.service.ItemCatService;
import com.jt.vo.EasyUITree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
public class ItemCatController {
    @Autowired
    private ItemCatService itemCatService;

    @RequestMapping("/item/cat/queryItemName")
    public String queryItemName( Long itemCatId){
        ItemCat itemCat= itemCatService.queryItemName(itemCatId);

        return itemCat.getName();
    }


//参数传递本质
  /*  public String example(HttpServletRequest request, HttpServletResponse response){
        String itemCatId= request.getParameter("");
        Long id=Long.parseLong(itemCatId);

    }*/
    /*@RequestMapping("/item/cat/list")
    public List<EasyUITree> findItemCatList(Long id){
        long parentId= (id==null)?0:id;
        return itemCatService.findItemCatList(parentId);


    }*/

    @RequestMapping("/item/cat/list")
    public List<EasyUITree> findItemCatList(Long id){
        long parentId=(id==null)?0:id;
        return itemCatService.findItemCatList(parentId);
//        return itemCatService.findItemCatCache(parentId);
    }
}
